package com.trs.publish.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trs.publish.domain.User;
import com.trs.publish.repository.UserRepository;


/**
 * @author jiahaihong
 */
@Service
public class UserService {

	@Autowired
    private UserRepository userRepository;

	public User findByName(String username) {
		return userRepository.findByName(username);
	}

	public User query(String username, String password) {
		return userRepository.findByNameAndPassword(username,password);
	}

	public List<User> getList(User user) {
		return userRepository.findByUser(user);
	}
	
	@Transactional
	public void deleteUser(long id) {
		userRepository.delete(id);
	}

	public User findById(long id) {
		return userRepository.find(id);
	}
	
	@Transactional
	public void update(User user) {
		userRepository.update(user);
	}
	
	@Transactional
	public void save(User user) {
		userRepository.save(user);
	}



}
